﻿/****************
* Authored by Zhuo "Wizcas" Chen
* 2018 © Wubi.fun all rights reserved
*****************/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[System.Serializable]
public struct Res
{
    public static readonly Res empty = new Res();

    public string id;
    public string name;
    public int amount;
    public int score;
    public bool isValid { get { return !string.IsNullOrEmpty(id); } }

    Sprite _ic;
    public Sprite icon { get { return _ic ?? (_ic = Resources.Load<Sprite>(string.Format("Res/{0}", id))); } }

    public Res MakeAmount(int amt)
    {
        return new Res { id = id, name = name, amount = amt };
    }

    public override string ToString()
    {
        return string.Format("[{0}]{1}{2}", id, name, amount != 0 ? string.Concat(" > ", amount) : string.Empty);
    }
}